import 'dart:io';

import 'package:dio/dio.dart';
import 'package:shop/config/service_url.dart';

Future request(url,{formData}) async{
  try{
    Response response;
    Dio dio = new Dio();
    dio.options.contentType = "application/x-www-form-urlencoded";
    if(formData==null){
      response = await dio.post(servicePath[url]!);
    }else{
      response = await dio.post(servicePath[url]!,data: formData);
    }
    if(response.statusCode==200){
      return response.data;
    }else{
      throw Exception('后端接口出现异常，请检查代码和服务器情况......');
    }
  }catch(e){
    return print('Error:=====>$e');
  }
}